
// Function Types

interface SearchFunc {
  (source: string, subString: string): boolean; // 接口对于参数及返回值进行约束，但对于参数检测并不是强制的
}

let mySearch: SearchFunc;
mySearch = function(source: string, subString: string) {
    let result = source.search(subString);
    return result > -1;
}

let mySearchs: SearchFunc;
// 对于参数校验，不是强制的，可以写其他属性
mySearchs = function(src, sub) {
    let result = src.search(sub);
    return result > -1;
}


let mySearchss: SearchFunc;
// Type '(src: string, sub: string) => string' is not assignable to type 'SearchFunc'.
//   Type 'string' is not assignable to type 'boolean'
mySearchss = function(src, sub) {
    let result = src.search(sub);
    return 'string'; // 返回值进行约束
}

